<!-- 管控规则 -->
<template>
  <a-card title="管控规则" :bordered="false">
    <div v-for="(item, index) in controlRuleList" :key="item.key" class="cr-box">
      <a-switch v-model="item.isDim" :disabled="isLook" />
      <div class="name">当</div>
      <ASelectList style="width: 200px;" v-model="item.dimType" :disabled="isLook" :isHasDict="false" :defaultOption="dimTypeOption" @change="dimTypeChange(item)" />
      <div class="name">的</div>
      <a-select style="width: 600px;" mode="multiple" v-model="item.dimValue" :disabled="isLook">
        <a-select-option v-for="(cItem, cIndex) in item.dimValueOption" :key="cIndex">{{ cItem.label }}</a-select-option>
      </a-select>
      <div class="name">风险发生时，则自动触发</div>
      <ASelectList style="width: 300px;" v-model="item.dimRemark" :disabled="isLook" :isHasDict="false" :defaultOption="dimRemarkOption" />
      <div v-show="!isLook" class="name">
        <span class="cus-text" pointer @click="onControlRuleAdd"><a-icon type="plus" />添加</span>
      </div>
      <div v-show="!isLook && index > 0" class="name">
        <span class="cus-text" pointer danger @click="onControlRuleDelete(index)">删除</span>
      </div>
    </div>
  </a-card>
</template>

<script>
export default {
  name: 'MonitoringDimensionality',
  props: {
    isLook: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {
      dimList: [
        {
          label: '全部',
          tabList: [
            { label: '全部维度', value: 'all' }
          ]
        },
        {
          label: '重大事件',
          tabList: [
            { label: '注册资金变更', value: 'registerCapitalChange' },
            { label: '企业类型变更', value: 'enterpriseTypeChange' },
            { label: '证照号变更', value: 'licenseNumChange' },
            { label: '分支机构变更', value: 'branchOfficeChange' },
            { label: '司法拍卖', value: 'judicialAuction' },
            { label: '动产抵押', value: 'chattelMortgage' },
            { label: '股权出质', value: 'equityPledge' },
            { label: '欠税信息', value: 'oweTaxInfo' },
            { label: '经营异常', value: 'operatingAnomaly' },
            { label: '失信信息', value: 'breakPromiseInfo' },
            { label: '法人被执行', value: 'legalPersonExecution' },
            { label: '重大违法逃税', value: 'majorIllegalTaxEvasion' },
          ]
        },
        {
          label: '中度事件',
          tabList: [
            { label: '经营范围变更', value: 'businessScopeChange' },
            { label: '负责人变更', value: 'chargePersonChange' },
            { label: '股东股权变更', value: 'stockholderEquityChange' },
            { label: '投资变更', value: 'investChange' },
            { label: '人员变更', value: 'staffChange' },
            { label: '企业名称变更', value: 'enterpriseNameChange' },
            { label: '隶属关系变更', value: 'membershipChange' },
          ]
        },
        {
          label: '轻度事项',
          tabList: [
            { label: '地址变更', value: 'addressChange' },
            { label: '联系方式变更', value: 'contactInfoChange' },
            { label: '期限变更', value: 'timeLimitChange' },
            { label: '裁判文书', value: 'judicialDocument' },
            { label: '法院公告', value: 'courtAnnouncement' },
            { label: '开庭公告', value: 'openAnnouncement' },
            { label: '行政处罚', value: 'administrativePunishment' },
            { label: '司法协助', value: 'judicialAssistance' },
            { label: '股权冻结', value: 'equityFreeze' },
            { label: '立案信息', value: 'filingInfo' },
          ]
        },
        {
          label: '提醒事项',
          tabList: [
            { label: '其他变更', value: 'otherChange' },
            { label: '商标信息', value: 'trademarkInfo' },
            { label: '专利信息', value: 'patentInfo' },
            { label: '新闻动态', value: 'newsTrends' },
            { label: '抽查检查', value: 'spotCheck' },
            { label: '招投标', value: 'bid' },
            { label: '对外投资', value: 'outwardInvestment' },
            { label: '软件著作权', value: 'softwareCopyright' },
          ]
        },
      ],
      controlRuleList: [
        { key: String(new Date()), isDim: false, dimType: '', dimValue: [], dimRemark: '', dimValueOption: [] }
      ],
      dimTypeOption: [
        { label: '重大事件', value: '1' },
        { label: '中度事件', value: '2' },
        { label: '轻度事项', value: '3' },
        { label: '提醒事项', value: '4' },
      ],
      dimRemarkOption: [
        { label: '冻结监控供应商', value: '1' },
        { label: '申购时无法选择供应商', value: '2' },
      ],
    }
  },
  methods: {
    setParams() {},
    getParams() {},
    dimTypeChange(item) {
      item.dimValue = [];
      item.dimValueOption = this.dimList[item.dimType - 0].tabList;
    },
    onControlRuleAdd() {
      this.controlRuleList.push({ key: String(new Date()), isDim: false, dimType: '', dimValue: [], dimRemark: '', dimValueOption: [] })
    },
    onControlRuleDelete(index) {
      this.controlRuleList.splice(index, 1);
    },
  }
}
</script>

<style lang="less" scoped>
.cr-box {
  display: flex;
  align-items: center;
  margin-top: 20px;
  &:first-child {
    margin-top: 0;
  }
  .name {
    flex-shrink: 0;
    margin: 0 8px;
  }
}
</style>